import os
import time
import shutil

def log(*args):
    print(*args)

def run(command):
    print(command)
    os.system(command)

def ln(src, dst):
    run(f'ln -s {src} {dst}')

def is_root():
    return os.getuid() == 0

def ensure_root():
    if not is_root():
        raise Exception("need root!")

def file_backup(path):
    p = os.path.expanduser(path)
    shutil.copyfile(p, f'{p}.bak.{time.time()}')

def file_delete(path):
    p = os.path.expanduser(path)
    os.remove(p)

def file_exists(path):
    p = os.path.expanduser(path)
    return os.path.exists(p)
